from django.db import models
from django.contrib import auth
    
class Book(models.Model):    
    def __unicode__(self):
        return self.title

    uuid = models.CharField(max_length=100, primary_key=True)
    title = models.CharField(max_length=100)
    isbn_13 = models.IntegerField()
    description = models.CharField(max_length=1000)
    image_url = models.CharField(max_length=200)
    
class Price(models.Model):
    pid = models.IntegerField(primary_key=True)
    book = models.ForeignKey(Book)
    price = models.FloatField()
    purchase_url = models.CharField(max_length=200)
    condition = models.CharField(max_length=20)
    vendor = models.CharField(max_length=100)
    
    class Meta:
        ordering = ["price"]

class Author(models.Model):
    aid = models.FloatField(primary_key=True)
    book = models.ForeignKey(Book)
    author = models.CharField(max_length=100)

class Query(models.Model):
    query = models.CharField(max_length=100)
    time = models.DateTimeField()
    uid = models.ForeignKey(auth.models.User,blank=True,null=True)
    
    class Meta:
        ordering = ["time"]